package tests;

import common.Utils;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;

import java.io.IOException;

public class ListPage extends Utils {
    public static String url = "http://8.137.19.140:9090/blog_list.html";

    public ListPage() {

        super(url);

    }
    //测试登入状态下
    public void ListLogin() throws IOException {
        //检查页面元素
        driver.findElement(By.cssSelector("body > div.container > div.left > div > img"));
        driver.findElement(By.cssSelector("body > div.container > div.left > div > h3"));
    }
    //测试能否跳转到博客详情页
    public void ListLogin1(){
        //找到元素并点击
        driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > a")).click();
        //检查是否有元素确认是否跳转页面
        driver.findElement(By.cssSelector("body > div.container > div.left > div > h3"));
        String exp = driver.getTitle();
        assert exp.equals("博客详情页");
    }
    public void ListLogin2(){
        //找到元素并点击
        driver.findElement(By.cssSelector("body > div.nav > a:nth-child(5)")).click();
        //检查是否有元素确认是否跳转页面
        driver.findElement(By.cssSelector("#h2-u5728u8FD9u91CCu5199u4E0Bu4E00u7BC7u535Au5BA2"));
        //标题确认
        String exp = driver.getTitle();
        assert exp.equals("博客编辑页");

    }
}
